const createBaseLineOption = ({ legend, yAxisName }) => ({
  tooltip: { trigger: 'axis' },
  legend: { data: legend },
  xAxis: { type: 'category', data: [] },
  yAxis: { type: 'value', name: yAxisName },
  series: legend.map((name) => ({
    name,
    type: 'line',
    smooth: true,
    data: [],
    symbol: 'circle',
    symbolSize: 8,
    itemStyle: {
      borderWidth: 0
    }
  }))
})

export const createTemperatureOption = (timestamps = [], calibrated = [], measured = []) => {
  const option = createBaseLineOption({
    legend: ['末站进站模拟温度', '末站进站实测温度'],
    yAxisName: '温度 (°C)'
  })

  option.xAxis.data = timestamps
  option.series[0].data = calibrated
  option.series[1].data = measured

  return option
}

export const createPressureOption = (timestamps = [], calibrated = [], measured = []) => {
  const option = createBaseLineOption({
    legend: ['出站压力校准值', '出站压力实测值'],
    yAxisName: '压力 (MPa)'
  })

  option.xAxis.data = timestamps
  option.series[0].data = calibrated
  option.series[1].data = measured

  return option
}
